//
//  PhoneLogInView.swift
//  ShiZhe
//
//  Created by 陈卿伟 on 16/8/31.
//  Copyright © 2016年 陈卿伟. All rights reserved.
//

import UIKit

class PhoneLogInView: UIView {
    var phoneNumber:UITextField!//电话号码输入框
    var password:UITextField!//密码输入框
    var logButton:UIButton!//登录按钮
    var smsLogLabel:UILabel!//短信登录label
    var forgotPassword:UILabel!//忘记密码
    
    override init(frame: CGRect) {
        phoneNumber = UITextField()
        password = UITextField()
        logButton = UIButton()
        smsLogLabel = UILabel()
        forgotPassword = UILabel()
        super.init(frame: frame)
        self.createPhoneNPasswordTextF()
        self.createLogButton()
        self.createSMSLogInLabelAndForgotPassword()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        phoneNumber.resignFirstResponder()
        password.resignFirstResponder()
    }
    
    
    //创建 手机号和密码输入框
    func createPhoneNPasswordTextF(){
        phoneNumber.frame = CGRect(x: 32*SCALEW, y: 27*SCALEH, width: 311*SCALEW, height: 39*SCALEH)
        phoneNumber.placeholder = "请输入手机号"
        phoneNumber.keyboardType = .NumberPad
        phoneNumber.font = BaseFunc.getSystemFont(14.5)
        phoneNumber.backgroundColor = UIColor.whiteColor()
        let view1 = UIView(frame: CGRect(x: 0,y: 0,width: 10,height: 1))
        phoneNumber.leftView = view1
        phoneNumber.leftViewMode = .Always
        phoneNumber.layer.borderWidth = 1
        phoneNumber.layer.borderColor = BaseFunc.createCustomColor(240, b: 240, g: 240, a: 1).CGColor
        phoneNumber.layer.cornerRadius = 5
        self.addSubview(phoneNumber)
        
        password.frame = CGRect(x: 32*SCALEW, y: 82*SCALEH, width: 311*SCALEW, height: 39*SCALEH)
        password.placeholder = "请输入密码"
        password.keyboardType = .Default
        password.font = BaseFunc.getSystemFont(14.5)
        password.backgroundColor = UIColor.whiteColor()
        let view2 = UIView(frame: CGRect(x: 0,y: 0,width: 10,height: 1))
        password.leftView = view2
        password.leftViewMode = .Always
        password.layer.borderWidth = 1
        password.layer.borderColor = BaseFunc.createCustomColor(240, b: 240, g: 240, a: 1).CGColor
        password.layer.cornerRadius = 5
        password.secureTextEntry = true
        self.addSubview(password)
    }
    
    
    //创建登录按钮
    func createLogButton(){
        logButton.frame = CGRect(x: 33*SCALEW, y: 145*SCALEH, width: 309*SCALEW, height: 50*SCALEH)
        logButton.titleLabel?.font = BaseFunc.getCustomFont(18)
        logButton.setTitle("登录", forState: UIControlState())
        logButton.backgroundColor = UIColor.blackColor()
        logButton.layer.cornerRadius = 5
        self.addSubview(logButton)
    }
    
    
    //创建短信登录 和找回密码 label
    func createSMSLogInLabelAndForgotPassword(){
        smsLogLabel.frame = CGRect(x: 33*SCALEW, y: 222*SCALEH, width: 150*SCALEW, height: 19*SCALEH)
        smsLogLabel.font = BaseFunc.getCustomFont(16)
        smsLogLabel.textColor = Theme.GrayColor
        smsLogLabel.text = "短信验证码登录"
        smsLogLabel.textAlignment = .Left
        smsLogLabel.userInteractionEnabled = true
        self.addSubview(smsLogLabel)
        
        forgotPassword.frame = CGRect(x: WidthAPP-33*SCALEW-100*SCALEW, y: 222*SCALEH, width: 100*SCALEW, height: 19*SCALEH)
        forgotPassword.font = BaseFunc.getCustomFont(16)
        forgotPassword.textColor = Theme.GrayColor
        forgotPassword.text = "忘记密码"
        forgotPassword.textAlignment = .Right
        forgotPassword.userInteractionEnabled = true
        self.addSubview(forgotPassword)
    }
}
























